package jpal.base;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.List;

import jpal.base.MoreArrays;

import org.junit.Test;

public class MoreArraysTest {

	final Double[] array = { 1.5, 2.5, 5.5, 3.5, 4.5, 5.5 };

	@Test
	public void contains() {
		assertTrue(MoreArrays.contains(array, 2.5));
		assertFalse(MoreArrays.contains(array, 9));
	}

	@Test
	public void indexOf() {
		final List<Double> list = Arrays.asList(array);
		assertTrue(list.indexOf(1.5) == MoreArrays.indexOf(array, 1.5));
		assertTrue(list.indexOf(5.5) == MoreArrays.indexOf(array, 5.5));
		assertTrue(list.indexOf(-1) == MoreArrays.indexOf(array, -1));
	}

	@Test
	public void lastIndexOf() {
		final List<Double> list = Arrays.asList(array);
		assertTrue(list.lastIndexOf(1.5) == MoreArrays.lastIndexOf(array, 1.5));
		assertTrue(list.lastIndexOf(5.5) == MoreArrays.lastIndexOf(array, 5.5));
		assertTrue(list.lastIndexOf(-1) == MoreArrays.lastIndexOf(array, -1));
	}

}
